new Vue({
    el: '#container',
    delimiters: ['${', '}'],
    data() {
        return {
            system_id: '',
            system_name: '',
            system_url:'',
            system_version: '',
            system_desc: ''
        }
    },
    mounted() {},
    methods: {
        addProjectItem() {
            this.system_id = '';
            this.system_name = '';
            this.system_version = '';
            this.system_url='';
            this.system_desc = ''
            $('#myDialog').modal()
        },
        clickGroup(id){
          sessionStorage.setItem('group',id);
        location.href=`  /admin/api?system_id=${id}`
      },
        //添加接口
        submitMethods() {
            let url = this.system_id?'/admin/edit' : '/admin/project'
            let params = {
                system_name: this.system_name,
                system_version: this.system_version,
                system_url:this.system_url,
                system_desc: this.system_desc

            }
            console.log(params)
            if (this.system_id) {
                params.system_id = this.system_id
            }
            $.ajax({
                url: url,
                type: "POST",
                data: params,
                dataType: "json",
            }).then((res) => {
                if (res.success) {
                    location.reload();
                }
            })
        },
        //删除接口
        deleteProject(id) {
            let flag = confirm('确定删除该接口?此项目下的所有接口都将删除，请谨慎操作，不可逆回！！！！！！');
            if (flag == true) {
                $.ajax({
                    url: `/admin/delproject?system_id=${id}`,
                    type: "GET",
                    dataType: "json",
                }).then((res) => {
                    if (res.success) {
                        location.reload();
                    }
                })
            }


        },
        editProject(id, name, version, desc,url) {
            this.system_id = id;
            this.system_name = name;
            this.system_version = version;
            this.system_url=url
            this.system_desc = desc
            $('#myDialog').modal()
        },

    }
})